<?php

class UserIdentity extends CUserIdentity
{
    private $_iUserId;
    private $_oUser;
    
    public function authenticate()
    {
        $oUser = User::model()->findByAttributes(array('user_login' => $this->username, 'user_password' => md5($this->password), 'status' => 'active'));

        if ( !is_null($oUser) )
        {
            $this->_iUserId  = $oUser->user_id;
            $this->_oUser    = $oUser;
            $this->setState('user_login', $oUser->user_login);
            
            return true;
        }
        
        return false;
    }
    
    public function getId()
    {
        return $this->_iUserId;
    }
    
    public function getUser()
    {
        return $this->_oUser;
    }
}